<template>
  <div class="pagination">
    <el-pagination :total="totalSize" :current-page="currentPage" :page-size="pageSize" background
      layout="prev, pager, next, jumper" @current-change="handleCurrentChange" />
  </div>
</template>

<script>
export default {
  name: "",
  components: {},
  props: {
    numberOfElements: {
      type: [String, Number],
      default: 1
    },
    currentPage: {
      type: [String, Number],
      default: 1
    },
    pageSize: {
      type: [String, Number],
      default: 10
    },
    totalSize: {
      type: [String, Number],
      default: 0
    }
  },
  data () {
    return {};
  },
  watch: {
    'totalSize': {
      handler (v) {
        if (v % 10 == 0 && v) {
          let currentPage = this.currentPage
          currentPage--
          this.$emit("changeCurrentPage", currentPage ? currentPage : 1);
        }
      }
    }
  },
  created () { },
  mounted () { },
  methods: {
    handleSizeChange (pagesize) {
      this.$emit("changePageSize", pagesize);
    },
    handleCurrentChange (currentPage) {
      this.$emit("changeCurrentPage", currentPage);
    }
  }
};
</script>

<style scoped lang="scss">
@import "~@/styles/variables.scss";

.pagination {
  position: absolute;
  right: 0px;
  bottom: 0px;

  ::v-deep .el-pagination {
    color: #fff;

    button {
      // background-color: #0092b8;
      background-color: transparent;
      border: 1px solid #0092b8;
      border-radius: 4px;
      color: #0092b8;
    }

    .el-pagination__total,
    .el-pagination__jump {
      color: #5DAEFC;
    }

    .el-pager {

      .number,
      .more {
        background-color: transparent;
        border: 1px solid #0092b8;
        border-radius: 4px;
        color: #0471DD;

        &:hover {
          color: #fff;
          background-color: #0092b8;
        }
      }

      .active {
        background-color: #0079F0 !important;
      }
    }

    .el-pagination__editor.el-input {
      .el-input__inner {
        height: 28px !important;
        color: #0471DD;
      }
    }
  }
}
</style>
